package com.mk.graphql.repository;

import com.mk.graphql.entity.Author;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Component
public class Repository {
    private Map<Long, Author> authorMap = new HashMap<>();

    public void put(Long key, Author value) {
        authorMap.put(key, value);
    }

    public void del(Long key) {
        authorMap.remove(key);
    }

    public Author get(Long key) {
        return authorMap.get(key);
    }

    @PostConstruct
    public void init() {
        authorMap.put(1L, new Author(1L, "1name", "1男", new Date(), null));
        authorMap.put(2L, new Author(2L, "2name", "2男", new Date(), null));
    }
}
